package com.powernode.utils;

import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 内容:
 * 作者: cy
 * 获取当前用户 店铺的工具类
 */
public class AuthUtil {


    public static Long getUserIdOrShopId(Boolean isUser) {
        String userIdAndShopId = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
        return isUser ? Long.valueOf(userIdAndShopId.split("-")[0]) : Long.valueOf(userIdAndShopId.split("-")[1]);
    }


    public static String getOpenId() {
        return SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
    }


}
